package demo;



import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.util.List;

import org.htmlcleaner.TagNode;
import org.htmlcleaner.XPatherException;

import lib.ConnectionWeb;
import lib.OneMenuHasClickFilter;
import lib.OneMenuNoClickFilter;
import lib.StringEdit;
import lib.TwoMenuFilter;

public class demo4 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String url="http://www.vinabook.com/";
		ConnectionWeb con= new ConnectionWeb();
		String xpath="ul/li";
		String xp="ul style=\"padding:0px\"/b";
		
		TagNode root=con.getInfo(url);

		List<TagNode> l=con.executeXpath2(root, xpath,20);
		
		for(int i=0; i< l.size();i++)
		{
			TagNode t=l.get(i);
			List<?> lNode= t.getElementListByName("a", true);
			for(int j= 0; j< lNode.size();j++)
			{
				TagNode t1= (TagNode) lNode.get(j);

				String tlink=StringEdit.EditLink(url,t1.getAttributeByName("href"));
				tlink= StringEdit.EditLink(url, tlink);
				TagNode root2 = con.getInfo(tlink);
				
				List<TagNode> l2=con.executeXpath2(root2, xp,1);
				System.out.print(l2.size());
			}
		}
	
	
	}

}
